#ifndef SERVER_H
#define SERVER_H

#include <boost/asio.hpp>
namespace asio = boost::asio;

#include "network/asio_dgram_conn.h"

#include "server_conn.h"

class Server {
	private:
		server_options opt;
		asio::io_service& service;
		asio::ip::udp::socket udpsock;
		UdpService udpservice;

		static const int udppackbufsize = sizeof(dgram::packet);
		uint8 udppackbuf[udppackbufsize];
		asio::ip::udp::endpoint udppeer;

		void handle_udp_receive(const boost::system::error_code& e, std::size_t len);
		void handle_udp_accept(const boost::system::error_code& e, ServerConnRef conn);

	public:
		Server(asio::io_service& service_, const server_options& opt_);
};

#endif
